<!--
 * @Author: ChenCaoYang
 * @Date: 2021-05-29 19:27:52
 * @LastEditors: YaoXiaoTian
 * @LastEditTime: 2021-06-15 16:32:44
-->
<template>
  <div class="container">
    <el-main>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
        header-row-class-name="header"
        cell-class-name="bodyer"
      >
        <el-table-column type="selection" width="50"> </el-table-column>
        <el-table-column prop="all" label="全选" width="55"> </el-table-column>
        <el-table-column prop="goods" label="商品" width="400">
          <template slot-scope="scope">
            <div style="height: 100px;" class="goods_box">
              <div style="width:100px;height:100px;">
                <img
                  :src="scope.row.titlePicUrl"
                  alt=""
                  style="width: 100%;height: 100%;"
                />
              </div>
              <div class="goods_info">
                <p>{{ scope.row.productName }}</p>
                <p>{{ scope.row.returnReason }}</p>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="单价" width="150" prop="price">
          <template slot-scope="scope">
            <div class="price">￥{{ scope.row.productPrice2 }}</div>
          </template>
        </el-table-column>
        <el-table-column label="数量" width="100" prop="number">
        </el-table-column>
        <el-table-column prop="count" label="总计" width="160">
          <template slot-scope="scope">
            <div class="count">￥{{ scope.row.saleCount }}</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="160">
          <template slot-scope="scope">
            <div class="oper">
              <p @click="postComments(scope.row.orderId)">评价</p>
              <p @click="wuliu(scope.row.orderId)" class="wuliu">查看详情</p>
              <el-button
                type="warning"
                round
                @click="tuihuo(scope.row.orderId)"
                size="small"
                >删除记录
              </el-button>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="110" prop="state">
          <template slot-scope="scope">
            <span v-if="scope.row.orderStatus == 0" class="over">待处理</span>
            <span v-if="scope.row.orderStatus == 1" class="over">待出库</span>
            <span v-if="scope.row.orderStatus == 2" class="over"
              >已出库,查看物流</span
            >
            <span v-if="scope.row.orderStatus == 3" class="ing">已签收</span>
            <span v-if="scope.row.orderStatus == 4" class="over">申请退换</span>
            <span v-if="scope.row.orderStatus == 5" class="over">退换成功</span>
            <span v-if="scope.row.orderStatus == 6" class="over">退换失败</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 确认收货 -->
      <div class="isOver">
        <el-button type="warning" round size="medium" @click="del"
          >删除</el-button
        >
      </div>
      <!-- 分页 -->
      <div class="footer">
        <el-pagination
          prev-text="上一页"
          next-text="下一页"
          background
          layout="prev, pager, next"
          :total="total"
          :page-size="9"
          hide-on-single-page
          @current-change="currentChange"
        >
        </el-pagination>
      </div>
    </el-main>
    <el-dialog
      title="申请退款"
      :visible.sync="dialogVisible"
      :destroy-on-close="true"
      :close-on-click-modal="false"
      width="572px"
    >
      <div class="content">
        <div class="title">退款商品</div>
        <div class="product_info">
          <div class="img">
            <img src="@/assets/imgs/orgin.jpg" alt="" />
          </div>
          <div class="product_name">
            <p class="title">新鲜现采沙田柚美味多汁酸甜可口农场直达</p>
            <p class="product_number">川味香肠458gx1(自然风干)</p>
          </div>
        </div>
        <div class="title">退款信息</div>
        <el-input
          class="test"
          type="textarea"
          :rows="5"
          v-model="tuikuanInfo"
          placeholder="退款描述，有助于商家更好的处理售后问题"
        ></el-input>
        <div class="money">
          <span>退款金额</span>
          <span>￥{{ "11000" }}</span>
        </div>
        <div class="isOver submit">
          <el-button type="warning" round size="medium">确认提交</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { get_data } from "../../../utils/utils";
export default {
  name: "allProducts",
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      multipleSelection: [],
      tuikuanInfo: "",
      total: 0,
      pageNo: 1,
      userInfo: {},
    };
  },
  mounted() {
    if (get_data("token")) {
      this.userInfo = JSON.parse(get_data("userInfo"));
    }
    this.getData();
  },
  methods: {
    getData() {
      this.$http
        .fetch(this.$apiPath.getReturnList, {
          methodType: "get",
          params: {
            customerId: this.userInfo.id,
            page: this.pageNo,
            rows: 10,
          },
        })
        .then((res) => {
          this.tableData = res.data.records;
          this.total = res.data.total;
        });
    },
    del() {
      //批量删除商品
      if (this.multipleSelection.length > 0) {
        for (const iterator of this.multipleSelection) {
          this.$http
            .fetch(this.$apiPath.delOrder, {
              method: "POST",
              data: {
                id: iterator.orderId,
              },
            })
            .then((res) => {
              if (res.code == 200) {
                this.$message("删除完成");
                this.tableData = [];
                this.multipleSelection = [];
                this.total = 0;
                this.getData();
              }
            });
        }
      } else {
        this.$message("请先选择商品");
        return;
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    wuliu() {
      this.$router.push({
        path: "/order/refundDetails",
      });
    },
    currentChange(current) {
      this.pageNo = current - 1;
      this.getData();
    },
    handleSelect() {},
    tuihuo() {
      this.dialogVisible = true;
    },
    postComments() {
      this.$router.push({
        path: "/order/postComments",
      });
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  .over {
    font-size: 14px;
    font-weight: 600;
    color: #333333;
  }
  .ing {
    font-size: 14px;
    font-weight: 600;
    color: #ff6c00;
  }
  /deep/.el-table th > .cell {
    text-align: center;
  }
  /deep/.bodyer {
    text-align: center;
  }
  /deep/.el-checkbox__input.is-checked .el-checkbox__inner {
    background-color: #cf975a;
    border: #cf975a;
  }
  /deep/.el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #cf975a;
    border: #cf975a;
  }
  /deep/.el-checkbox__inner {
    border-radius: 50% !important;
  }
  .goods_box {
    box-sizing: border-box;
    display: flex;
    .goods_info {
      padding: 25px 0;
      margin-left: 23px;
      p:first-child {
        font-size: 14px;
        font-family: PingFangSC;
        font-weight: 400;
        color: #666666;
        margin-bottom: 10px;
      }
      p:last-child {
        font-size: 12px;
        font-family: Source Han Sans CN;
        font-weight: 300;
        color: #999999;
      }
    }
  }
  .price,
  .count {
    font-size: 18px;
    font-weight: 500;
    color: #ff9933;
  }
  .oper {
    .is-round {
      padding: 9px 29px;
    }
    p:first-child {
      font-size: 14px;
      font-weight: 400;
      color: #999999;
      cursor: pointer;
    }
    .wuliu {
      font-size: 14px;
      font-weight: 400;
      color: #ff9933;
      cursor: pointer;
      margin-bottom: 8px;
    }
  }
  .isOver {
    overflow: hidden;
    padding-right: 50px;
    margin-top: 67px;
    button {
      float: right;
      padding: 18px 55px;
      background: #cf975a;
      border-radius: 28px;
    }
  }
  .el-dialog__title {
    font-size: 30px;
    font-weight: 500;
    color: #5c5f68;
    margin-top: 10px;
  }
  .content {
    .title {
      font-size: 18px;
      font-weight: 400;
      color: #333333;
    }
    .product_info {
      display: flex;
      margin-top: 20px;
      align-items: center;
      margin-bottom: 20px;
      .img {
        width: 100px;
        height: 100px;
        margin-right: 24px;
        img {
          width: 100%;
          height: 100%;
          border-radius: 5px;
        }
      }
      .product_name {
        height: 49px;
        width: 406px;
        .title {
          margin-bottom: 10px;
          font-size: 14px;
          font-weight: 600;
          color: #666666;
          width: 100%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .product_name {
          font-size: 12px;
          font-weight: 300;
          color: #9999;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
    .test {
      margin-top: 20px;
      margin-bottom: 30px;
    }
    .money {
      span:last-child {
        float: right;
        font-size: 18px;
        font-weight: 400;
        color: #ff9933;
      }
    }
    .submit {
      padding-right: 0;
      display: flex;
      justify-content: center;
    }
  }
  /deep/.footer {
    padding: 0;
    margin: 0 auto;
    margin-top: 30px;
    margin-bottom: 33px;
    background-color: #ffffff;
    .btn-prev {
      width: 74px;
      height: 30px;
      border: 1px solid #c7c7c7;
      border-radius: 15px;
    }
    .btn-next {
      width: 74px;
      height: 30px;
      border: 1px solid #c7c7c7;
      border-radius: 15px;
      color: #999999;
    }
    .el-pager li {
      width: 30px;
      height: 30px;
      border: 1px solid #c7c7c7;
      border-radius: 15px;
      color: #999999;
    }
    .el-pager {
      .number {
        text-align: center;
        padding: 0;
      }
      //   .number:hover {
      //     color: #999999 !important;
      //   }
      li:not(.active).number:hover {
        color: #999999 !important;
      }
    }
    .el-pager li:not(.disabled).active {
      background-color: #cf975a;
    }
  }
}
</style>
